package com.gavindon.android.viewmodel

import androidx.lifecycle.viewModelScope
import com.gavindon.android.base.BaseViewModel
import com.gavindon.android.entity.CollectRecordResp
import com.gavindon.android.entity.StudyRecordResp
import com.gavindon.android.network.DataResult
import com.gavindon.android.repo.RecordRepo
import kotlinx.coroutines.launch

/**
 * description:
 * Created by liNan on  2022-2-11 15:06
 */
class RecordViewModel : BaseViewModel() {
    private val mRepo = RecordRepo()

    private val collectLiveData = SingleLiveEvent<DataResult<List<CollectRecordResp>>>()
    private val studyLiveData = SingleLiveEvent<DataResult<List<StudyRecordResp>>>()

    /*获取收藏记录*/
    fun getCollect(subjectType: Int): SingleLiveEvent<DataResult<List<CollectRecordResp>>> {
        viewModelScope.launch {
            val result = mRepo.getCollect(subjectType)
            collectLiveData.value = result
        }
        return collectLiveData
    }

    /*获取收藏记录*/
    fun getStudyRecord(): SingleLiveEvent<DataResult<List<StudyRecordResp>>> {
        viewModelScope.launch {
            val result = mRepo.getStudyRecord()
            studyLiveData.value = result
        }
        return studyLiveData
    }
}